package org.otarriinae.kaptcha.controller;

import org.orarriinae.common.web.result.ResponseBean;
import org.otarriinae.kaptcha.modle.Kaptcha;
import org.otarriinae.kaptcha.service.KaptchaService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author xj
 * @since 1.0
 */
@RestController
public class KaptchaController {

    private final KaptchaService kaptchaService;

    public KaptchaController(KaptchaService kaptchaService) {
        this.kaptchaService = kaptchaService;
    }

    /**
     * 获取验证码
     * @param key
     * @return
     */
    @GetMapping("/kaptcha")
    public ResponseBean<Kaptcha> getKaptcha(@RequestParam String key){
        return ResponseBean.success(kaptchaService.getKaptcha(key));
    }
}
